/**
 * 189. 轮转数组
 * https://leetcode.cn/problems/rotate-array/submissions/567829627/?envType=study-plan-v2&envId=top-100-liked
 */
class Solution {
    public void rotate(int[] nums, int k) {
        int n = nums.length;
        int[] tmp = new int[n];

        for(int i = 0; i < n; i++) {
            tmp[(i + k) % n] = nums[i];
        }

        System.arraycopy(tmp, 0, nums, 0, n);
    }
}